import java.util.Scanner;
public class Task20 {

	public static boolean areDifferent(int a){
		if(a%10 == (a/10)%10 || (a/10)%10 == (a/100)%10 || (a/100)%10 == a%10)
			return false;
		else
			return true;
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int counter = 0;
		int n = sc.nextInt();
		
		while(n<100){
			n = sc.nextInt();
		}
		sc.close();
		
		for(int i=100;i<1000;i++){
			if(i < n && areDifferent(i))
				counter++;
		}

		System.out.println("Number: " + counter);
		
	}

}
